<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>反馈</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../res/layui/css/layui.css">
    <link rel="stylesheet" href="../../res/css/bootstrap.min.css">
    <script src="../../res/js/jquery-3.1.1.min.js" charset="utf-8"></script>
    <script src="../../res/js/Tools.js"></script>
    <script src="../../res/layui/layui.js"></script>
    <style>
        .layui-form-label{
            width: 100px;
        }
    </style>

    <script type="text/javascript">
        //全局同步
        $.ajaxSetup({
            async: false
        });
    </script>
    <script type="text/javascript">
        $(function () {
            var resultExp = getQueryString("resultExp");
            if(resultExp != "null"){
                $("#testListAction").attr("class","layui-btn layui-btn-disabled");
                $("#testListAction").html("已反馈");
                $("#testListAction").attr("disabled","disabled");
                $("#resultExp").attr("readonly","readonly");
                $("#resultEffect").attr("readonly","readonly");
                $("#result").attr("readonly","readonly");
                $("#result").attr("onclick","");
                $("#i-check").attr("onclick","");
            }
        });
    </script>
</head>
<body>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>反馈</legend>
</fieldset>
<div><form class="layui-form" action="" id="inputForm" >
    <input type="text" name="schemeId" id ="schemeId" readonly="readonly" placeholder="方案id" autocomplete="off" class="layui-input" hidden>
    <input type="text" name="resultTime" id ="resultTime" lay-verify="required" readonly="readonly" placeholder="反馈时间" autocomplete="off" class="layui-input" hidden>
    <div class="layui-form-item">
        <label class="layui-form-label">实施情况</label>
        <div class="layui-input-block">
            <!--<input type="text" name="resultExp" id ="resultExp" lay-verify="required" placeholder="请输入实施情况" autocomplete="off" class="layui-input" >-->
            <textarea name="resultExp" id ="resultExp" lay-verify="required" placeholder="请输入实施情况" class="layui-textarea"></textarea>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">实施效果</label>
        <div class="layui-input-block">
            <!--<input type="text" name="resultEffect" id ="resultEffect" lay-verify="required" placeholder="请输入实施效果" autocomplete="off" class="layui-input" >-->
            <textarea name="resultEffect" id ="resultEffect" lay-verify="required" placeholder="请输入实施效果" class="layui-textarea"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">实施附件</label>
        <div class="form-group">
            <div class="col-sm-6">
                <div class="input-group">
                    <input id='result' name="result" lay-verify="files" class="form-control" readonly="readonly"  placeholder="请上传实施附件" onclick="$('#resultFiles').click();">
                    <label class="input-group-btn">
                        <input type="button" id="i-check" value="浏览文件" class="btn btn-primary" onclick="$('#resultFiles').click();">
                    </label>
                </div>
            </div>
            <input type="file" name="resultFiles" id='resultFiles' accept="*" onchange="$('#result').val($('#resultFiles').val());" style="display: none">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit="" id="testListAction" lay-filter="demo1">立即提交</button>
            <!--<button type="close" class="layui-btn layui-btn-primary" onclick="closeWindow()">关闭</button>-->
        </div>
    </div>
</form></div>

<script type="text/javascript">
    /**
     * 关闭当前弹出层
     */
    function closeWindow(){
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
        parent.layui.table.reload('schemeId');
    }

</script>

<script>
    layui.use(['form', 'layedit', 'layer', 'laydate','tree','util','upload'], function(){
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate
            , tree = layui.tree
            ,util = layui.util
            ,upload = layui.upload;

        form.render();

        laydate.render({
            elem: '#resultTime',
            value: new Date(),
            type: 'datetime'
        });

        //自定义验证规则
        form.verify({
            files: function(value){
                if(value.length == 0){
                    return '必须上传实施附件';
                }
            }

            ,content: function(value){
                layedit.sync(editIndex);
            }
        });


        var i = 0;
        //监听提交
        form.on('submit(demo1)', function(data){
            var url = "../../AtsSchemeController/updateByPrimaryKeySelective";
            var formData = new FormData(document.getElementById("inputForm"));
            //传输路径
            $.ajax({
                url:url,
                type:"post", // 传输类型
                data:formData, // 数据
                async:false, // 全局同步
                processData:false,
                contentType:false,
                dataType:"json",
                success:function(obj){
                    // alert("操作成功");
                    //     layer.alert("操作成功");
                    layer.msg(obj.msg,{
                        icon:1,
                        time:1000,
                    },function(){
                        closeWindow();
                    });
                    return false ;


                },
                error:function(e){
                    layer.msg(obj.msg,{
                        icon:1,
                        time:1000,
                    },function(){
                        closeWindow();
                    });
                    return false ;
                }
            });

            return false ;


        });


    });

</script>
</body>
</html>